"""
守护线程 - 不值得保留的线程，主线程一结束，守护线程自动停下来
"""
import time
from threading import Thread


def display(message):
    while True:
        print(message, end='', flush=True)
        time.sleep(0.01)


def main():
    # 通过Thread类初始化方法的daemon参数可以设置守护线程
    Thread(target=display, args=('Ping', ), daemon=True).start()
    Thread(target=display, args=('Pong', ), daemon=True).start()
    time.sleep(5)


if __name__ == '__main__':
    main()
